From 17a175e0514d5f01b3a9d196235906b53b7c2eaf Mon Sep 17 00:00:00 2001
From: Derek Lesho <dlesho@codeweavers.com>
Date: Fri, 17 Apr 2020 11:32:52 -0500
Subject: [PATCH] asfdemux: Re-initialize demux->adapter in
 gst_asf_demux_reset.

---
 gst/asfdemux/gstasfdemux.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/gst/asfdemux/gstasfdemux.c b/gst/asfdemux/gstasfdemux.c
index 6a6e3876..824a4355 100644
--- a/gst/asfdemux/gstasfdemux.c
+++ b/gst/asfdemux/gstasfdemux.c
@@ -208,11 +208,15 @@ gst_asf_demux_reset (GstASFDemux * demux, gboolean chain_reset)
 
   gst_segment_init (&demux->segment, GST_FORMAT_UNDEFINED);
   demux->segment_running = FALSE;
-  if (demux->adapter && !chain_reset) {
-    gst_adapter_clear (demux->adapter);
-    g_object_unref (demux->adapter);
-    demux->adapter = NULL;
+  if (!chain_reset) {
+    if (demux->adapter)
+    {
+      gst_adapter_clear (demux->adapter);
+      g_object_unref (demux->adapter);
+    }
+    demux->adapter = gst_adapter_new();
   }
+
   if (demux->taglist) {
     gst_tag_list_unref (demux->taglist);
     demux->taglist = NULL;
@@ -4816,6 +4820,9 @@ gst_asf_demux_finalize (GObject * object)
 {
   GstASFDemux *demux = GST_ASF_DEMUX (object);
 
+  if (demux->adapter)
+    demux->adapter = NULL;
+
   if (demux->metadata)
     gst_caps_unref (demux->metadata);
   demux->metadata = NULL;
-- 
2.24.1

